﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PMS.DAL
{
    public class UnitDAL
    {
        public bool IsExist(string strWhere)
        {
            string strsql = "select Id from P_Unit where UnitName='"+strWhere+"'";
            return Convert.ToBoolean(DBUtility.SQLHelper.Execute(strsql));
        }

        public bool Insert(PMS.Model.Unit unit)
        {
            string strsql = "insert into P_Unit (UnitName) values('"+unit.UnitName+"')";
            return Convert.ToBoolean(DBUtility.SQLHelper.Execute(strsql));
        }
        public IList<PMS.Model.Unit> GetList(string strWhere)
        {
            string strsql = "select Id,UnitName from P_Unit";
            System.Data.DataSet ds = DBUtility.SQLHelper.GetData(strsql);
            List<PMS.Model.Unit> unitList = new List<PMS.Model.Unit>();
            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
            {
                PMS.Model.Unit unit = new PMS.Model.Unit();
                unit.Id = (int)row[0];
                unit.UnitName = (string)row[1];
                unitList.Add(unit);
            }
            return unitList;
        }
    }
}
